package com.itheima.d9_interface_demo;

import javax.sound.midi.Soundbank;
import java.util.ArrayList;

public class StudentOperatorImpl1 implements StudentOperator {
    @Override
    public void printAllInfo(ArrayList<Student> students) {
        System.out.println("打印所有学生信息");
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            System.out.println("学生姓名" + student.getName() + ", 性别" + student.getGender() + "，成绩" + student.getScore());

        }
        System.out.println("------------");
    }

    @Override
    public void printAverageScore(ArrayList<Student> students) {
        double doubleAllScore = 0;
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            doubleAllScore += student.getScore();
        }
        System.out.println("平均成绩" + (doubleAllScore / students.size()));
        if (doubleAllScore / students.size() >= 60) {
            System.out.println("恭喜，班级平均分及格");
        }
    }
}
